package org.brownflat.lighthouse.monitoring.device;

import org.apache.log4j.Logger;
import org.brownflat.lighthouse.monitoring.action.Action;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class DefaultDeviceService implements DeviceService {

    private static final Logger LOG = Logger.getLogger(DefaultDeviceService.class);

    private Device device;
    private Action reset;
    private Action broken;
    private Action notBroken;

    @SuppressWarnings("unchecked")
    @Override
    public void reset() {
        LOG.debug("Resetting device..");
        device.execute(reset);
    }

    @SuppressWarnings("unchecked")
    @Override
    public void broken() {
        LOG.debug("Setting device to broken..");
        device.execute(broken);
    }

    @SuppressWarnings("unchecked")
    @Override
    public void notBroken() {
        LOG.debug("Setting device to not broken..");
        device.execute(notBroken);
    }

    public void setDevice(Device device) {
        this.device = device;
    }

    public void setReset(Action reset) {
        this.reset = reset;
    }

    public void setBroken(Action broken) {
        this.broken = broken;
    }

    public void setNotBroken(Action notBroken) {
        this.notBroken = notBroken;
    }
}
